import { Component, OnInit } from '@angular/core';
import {StoreProductService} from '../store-product.service';
import {NzMessageService} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';

@Component({
  selector: 'app-logistics',
  templateUrl: './logistics.component.html',
  styleUrls: ['./logistics.component.scss'],
  providers: [StoreProductService]
})
export class LogisticsComponent implements OnInit {

  order_no;
  order_info;
  express;
  _isSpinning = true;

  constructor(private orderService: StoreProductService,
              private _message: NzMessageService,
              private route: ActivatedRoute) { }

  ngOnInit() {
    this.order_no = this.route.snapshot.params['id'];

    this.getOrderLogistics();
  }

  getOrderLogistics() {
    this.orderService.getOrderLogistics(this.order_no).subscribe(res => {
      if (res.code === 2000) {
        this.order_info = res.data.order_info;
        this.express = res.data.express;
        this._isSpinning = false;
      } else {
        this._message.create('error', res.message);
      }
    });
  }
}
